package com.pinxixi.template.controller;

import com.pinxixi.api.template.TemplateControllerApi;
import com.pinxixi.framework.domain.template.Template;
import com.pinxixi.framework.model.response.ListResponseResult;
import com.pinxixi.framework.model.response.QueryResponseResult;
import com.pinxixi.framework.model.response.ResponseResult;
import com.pinxixi.template.service.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/template")
public class TemplateController implements TemplateControllerApi {

    @Autowired
    private TemplateService templateService;

    @Override
    @GetMapping("/findAll")
    public ListResponseResult<Template> findAll() {
        return templateService.findAll();
    }

    @Override
    @GetMapping("/findPage/{page}/{size}")
    public ListResponseResult<Template> findPage(@PathVariable("page") Integer page,
                                          @PathVariable("size") Integer size,
                                          Template template) {
        return templateService.findPage(page,size,template);
    }

    @Override
    @GetMapping("/findOne/{id}")
    public QueryResponseResult<Template> findOne(@PathVariable("id") Integer id) {
        return templateService.findOne(id);
    }


    @Override
    @PostMapping("/save")
    public ResponseResult save(@RequestBody Template template) {
        return templateService.save(template);
    }


    @Override
    @DeleteMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id) {
        return templateService.delelte(id);
    }

    @Override
    @DeleteMapping("/deleteAll")
    public ResponseResult deleteAll(Integer[] ids) {
        return templateService.delelteAll(ids);
    }

}
